package com.alog.senior.day07;

import java.util.Random;
import java.util.Scanner;

/**
 * @Auther: Ye Zhengdong
 * @Date: 2019/1/17 17:08
 * @Description:
 */
public class RandomDemo {
    public static void main(String[] args) {
        Random random = new Random();
        int num = random.nextInt(100) + 1;
        Scanner sc = new Scanner(System.in);
        while(true){
            System.out.println("请输入您猜的数字:");
            int num1 = sc.nextInt();
            if(num1 > num){
                System.out.println("太大了, 请重新猜");
            } else if(num1 < num){
                System.out.println("太小了, 请重新猜");
            } else {
                System.out.println("恭喜您, 猜中了");
                break;
            }
        }
    }
}
